var http = require('http');
var url = require('url');

function start(route, handle, port)
{
	var requestCount = 0;
	http.createServer(function(request, response) {
		requestCount++;
		//console.log('Request received. ['+requestCount+']');

		var pathname = url.parse(request.url).pathname;
		route(handle, pathname, request, response);
		
	}).listen(port);
	console.log('Server has running! Port at http://127.0.0.1:' + port + '/');
}
exports.Run = start;
